package com.bosssoft.g1.mapper;

import com.bosssoft.g1.dto.ResourceDTO;
import com.bosssoft.g1.entity.Resource;
import com.bosssoft.g1.vo.IdNameVO;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;

@org.apache.ibatis.annotations.Mapper
public interface ResourceMapper extends Mapper<Resource> {

    List<ResourceDTO> getAllRes();

    /**
     * 通过租户id查询资源树
     * @param tenantId
     * @return
     */
    List<Resource> queryResourcesByTenantId(@Param("tenantId") Long tenantId);

    /**
     * 通过子系统id查询资源树
     * @param susId
     * @return
     */
    List<Resource> queryResourceBySusId(@Param("susId") Long susId);

    @Select("SELECT * FROM basic_resource WHERE parent_id = #{parentId}")
    List<Resource> selectByParentId(@Param("parentId") Long parentId);

    List<IdNameVO> getAllSubsystem();

    /**
     * 根据资源id查询资源
     * @param id
     * @return
     */
    Resource queryResourceByResourceId(Long id);
}